package com.bidevalution.support.configuration;

import com.bstek.ureport.definition.datasource.BuildinDatasource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * 报表创建内置数据源
 */
public class ReportBuildDatasource implements BuildinDatasource {
    private DataSource dataSource;

    @Override
    public Connection getConnection() {
        try {
            return dataSource.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public String name() {
        return "内置数据源";
    }

    //这个是setter注入函数 setDataSource 注意大小写 以及拼写
    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }
}
